package com.fast.admin.common.shiro;

import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheException;
import org.apache.shiro.cache.CacheManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * @Title：reids的shiro缓存管理器
 * @author：ylc
 * @date：2018/7/31 11:27
 * @version：1.0
 **/
public class RedisCacheManager implements CacheManager {
    private long globExpire = 60;

    public RedisCacheManager() {

    }

    @Autowired
    private RedisTemplate redisTemplate;

    public RedisCacheManager(Long globExpire) {

    }

    @Override
    public <K, V> Cache<K, V> getCache(String name) throws CacheException {
        return new ShiroCache<K, V>(name, redisTemplate,globExpire);
    }
}
